<script setup>
// 在vue3 
import { useRoute,useRouter } from "vue-router"
// 获取路由对象 router useRouter
const router = useRouter()
// 获取路由参数 route useRoute
const route = useRoute()
const goList = () => {
  //console.log(router,route)
  router.push('/list')
}

// pinia操作
// import { useApiStore } from '@/stores/modules/api'
// const apiStore = useApiStore();

// import { useCounterStore } from '@/stores/modules/counter'
// const counterStore = useCounterStore();

import { useApiStore,useCounterStore } from '@/stores'

const apiStore = useApiStore();
const counterStore = useCounterStore();

import { ref } from 'vue'

import { getGoodsDetailService } from '@/api/goods.js'

const goodsData = ref([])


const getGoodsData = async () => {
  const res =  await getGoodsDetailService(122416);
  console.log(res)
  //goodsData.value = res.data.goods
}


 //const data = await getGoodsDetailService(122416)
//console.log(data)



</script>

<template>
  <div>我是APP.VUE</div>
  <button @click="$router.push('/home')">跳首页</button>
  <button @click="goList">跳列表</button>
  <div style="margin-top: 10px ;">
    <el-button @click="$router.push('/home')" type="danger">1111</el-button>
    <el-button @click="goList" type="error">2222</el-button>
  </div>


  <div style="margin-top: 50px ;">
    <p>{{ apiStore.access_token }}</p>
    <p>{{ apiStore.api_key }}</p>
    <el-button @click="apiStore.setAcccessToken('access_tokensssssss')" type="success">添加</el-button>
    <el-button @click="apiStore.setApikey('apikey')" type="success">添加api</el-button>
    <el-button @click="apiStore.removeAcccessToken()"   type="error">清空access_token</el-button>
    <el-button @click="apiStore.removeApikey()"  type="error">清空api</el-button>
  </div>

  <div style="margin-top: 50px ;">
    {{ counterStore.count }}
    <el-button  @click="counterStore.addCount(10)">加10</el-button>
  </div>


  <div style="margin-top: 50px ;">
    {{ goodsData }}
    <el-button  @click="getGoodsData()">获取商品详情</el-button>
  </div>

  

</template>

<style scoped>
</style>
